﻿#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QPainter>
#include <QDebug>
#include <QtMath>
#include <QFontMetrics>

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();

protected:
    void paintEvent(QPaintEvent *e) override;
    void resizeEvent(QResizeEvent *event) override;

private slots:
    void on_horizontalSlider_valueChanged(int value);

private:
    void getRectInfo();
    void drawOutBar(QPainter &p);
    void drawInBar(QPainter &p);
    void drawPoint(QPainter &p);
    void drawText(QPainter &p);

private:
    Ui::Widget *ui;
    int BarWidth = 20;        // 圆宽
    int minW;
    int value = 0;            // 初始值
};
#endif // WIDGET_H
